package com.zhiwei.gateway.controller;

import com.zhiwei.common.constant.ResultResponseMsg;
import com.zhiwei.gateway.service.CaptchaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * function 验证码控制器
 * author zhiwei.yang
 * time 2020-2-27-17:37
 */
@RestController
@RequestMapping("/captcha")
public class CaptchaController {

    @Autowired
    private CaptchaService captchaService;

    /**
     * 获取验证码服务
     * @param httpSession
     * @return
     */
    @GetMapping("/get")
    public ResultResponseMsg getCaptcha(HttpSession httpSession){
        String captcha = captchaService.getCaptcha(httpSession.getId());
        return ResultResponseMsg.buildSuccessResultMsg(captcha);
    }
}
